//
//  VideoControl.swift
//  Motion
//
//  Created by 悦月越悦 on 2021/3/19.
//

import SwiftUI
import SlideOverCard

struct VideoControl: View {
    @EnvironmentObject var videoPlayModel: VideoPlayModel
    
    @Binding var orientation: Orientation
    
    @State var show : Bool = false
    
    var body: some View {
        if(orientation == .portrait){
            VStack{
                HStack{
                    AssistButton()
                    Spacer()
                }
                
                Spacer()
                
                ActionDetailBtn()
                    .padding(.bottom, videoPlayModel.tipBtn ? 70:20)
                PlayControl()
                    .frame(height: 100)
            }
            .environmentObject(videoPlayModel)
        }
        
        if(orientation == .landscape){
            VStack{
                if(show){
                    HStack{
                        AssistButton()
                        Spacer()
                    }
                    
                    PlayControl()
                        .frame(height: 100)
                    
                    ActionDetailBtn()
                        .padding(.bottom,20)
                }
            }
            .frame(width: UIScreen.main.bounds.width,height: UIScreen.main.bounds.height)
            .background(Color.white.opacity(0.05))
            .onTapGesture (perform: {
                print("onTapGesture")
                show = true
                DispatchQueue.main.asyncAfter(deadline: .now() + 2) {
                    self.show = false
                }
            })
            .environmentObject(videoPlayModel)
        }
    }
}


